﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;

namespace Lamex.mNC.Common
{
    public class GetShowPic
    {
        public static List<string> ShowPic_STD(string DWGNo,string PartNo)
        {
            List<string> pathList = new List<string>();
            string Numbers = "";
            //显示图片
            XmlDocument doc = new XmlDocument();
            doc.Load(Application.StartupPath + "\\PicturePathConfig.xml");
            XmlNode xn = doc.SelectSingleNode("/Pictures/Picture");
            XmlNodeList xnl = xn.ChildNodes;
            string filename = "";//标准图纸路径             
            int Count = 0;

            foreach (XmlNode xn1 in xnl)
            {
                if (PartNo.Length > 3 && PartNo.Substring(1, 2) == "96")
                {
                    if (xn1.Name == "panelSjPath")
                    {
                        filename = xn1.InnerText;
                        Numbers = PartNo;
                    }     
                }
                else
                {
                    if (xn1.Name == "panlSdPath")
                    {
                        filename = xn1.InnerText;
                        Numbers = DWGNo;
                    }
                }
                //读取张数
                if (xn1.Name == "Sums")
                    Count = Convert.ToInt32(xn1.InnerText);
            }
            for (int i = 0; i < Count; i++)
            {
                string picTemp = "";//定义每张标准图片路径          
                if (i == 0)
                {
                    picTemp = filename + Numbers + ".tif";//标准图片只存在一张的情况
                }
                else
                {
                    picTemp = filename + Numbers + "-" + i + ".tif";//标准图片存在多张的情况
                }
                if (!File.Exists(picTemp))
                {
                    continue;
                }
                pathList.Add(picTemp);
            }
            return pathList;
        }
    }
}
